const Controller = require("egg").Controller;

class HomeController extends Controller {
  async index() {
    const userInfo = await this.ctx.service.User.find("122");
    this.ctx.body = userInfo;
  }

  async getFollowers() {
    const { pageSize = 10, pageNum = 1 } = this.ctx.query;
    const res = await this.ctx.service.githubService.index({
      pageSize,
      pageNum,
    });
    this.ctx.body = res.data;
  }

  async ejs() {
    const { ctx } = this;
    const { pageSize = 2, pageNum = 1 } = ctx.query;
    const items = await this.ctx.service.githubService.index({
      pageSize,
      pageNum,
    });
    await ctx.render("ejs.ejs", { items: items.data });
  }

  async handlebars() {
    const { ctx } = this;
    const items = await ctx.service.viewService.getItems();
    await ctx.render("handlebars.hbs", { items });
  }

  async nunjunks() {
    const { ctx } = this;
    const items = await ctx.service.viewService.getItems();
    await ctx.render("nunjunks.nj", { items });
  }
}

module.exports = HomeController;
